import React,{FC,useEffect} from 'react';
import ElForm from './form';
import {useSelector,useDispatch,ConsumerModelState}  from 'umi';
import addUserConfig from '@/utils/add_user_config';
import style from './addUser.less';

const AddUser:FC = () => {

    const dispatch = useDispatch();
    useEffect(() => {
        ////获取身份id
        dispatch({
            type:'consumer/getUserIdentity'
        })

        //获取api接口权限数据

        dispatch({
            type:'consumer/getApiAuthority'
        })

        //获取视图权限数据

        dispatch({
            type:'consumer/getViewAuthority'
        })
    },[])

    const data = useSelector((model:{consumer:ConsumerModelState}) => model.consumer);

    return <div className={style.wrap}>
        {addUserConfig.map(item => <ElForm item={item} key={item.id} data={data}></ElForm>)}
    </div>
}

export default AddUser